****APPENDIX TABLE E3-E6****

cd "$main_dir/output/tables/appendix_e"

global basic 	marital edu
global econ	    employment_status occupation income imputed_income
global design 	survey_year age language
global polit    ideology party_member

//--------------------------------------------------------
//Define relevant program
//--------------------------------------------------------

capture program drop standardize
program define standardize
	
	args depvar
	
	cap drop z*
	local varlist `depvar' wgrowth_rate_1
	foreach var of local varlist {
		egen z`var' = std(`var') if e(sample)==1
}														

end

capture program drop standardize_var
program define standardize_var
	
	args var
	
	cap drop z*
	local varlist trust_fed_govt_med wgrowth_rate_1 `var'
	foreach var of local varlist {
		egen z`var' = std(`var') if e(sample)==1
}														

end

//--------------------------------------------------------
//Read in relevant data
//--------------------------------------------------------

clear
use "$data_dir/clean/shp_final_panel.dta"

gen dummy = 1 if trust_fed_govt_med!=.
bys idpers: egen total_obs = total(dummy)

xtset idpers survey_year

cap drop sample income_sample
gen sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=15 & age!=.
gen income_sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=18 & age!=. & total_real_income_with_0_obs>=0.5*(age-18) & total_real_income_with_0_obs!=.

egen canton_survey_year = group(canton survey_year)

//--------------------------------------------------------
//Create Table E3 (Panel A)
//--------------------------------------------------------

qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idpers) cluster(idpers)
standardize trust_fed_govt_med

reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idpers)
outreg2 using table_e3_panel_a.doc, replace dec(3) nocons addtext(Cluster, Individual) keep(zwgrowth_rate_1) 
													   
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(yob)
outreg2 using table_e3_panel_a.doc, append dec(3) nocons addtext(Cluster, Cohort) keep(zwgrowth_rate_1) 
																   
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(canton)
outreg2 using table_e3_panel_a.doc, append dec(3) nocons addtext(Cluster, Canton) keep(zwgrowth_rate_1) 		
		
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(canton yob)
outreg2 using table_e3_panel_a.doc, append dec(3) nocons addtext(Cluster, Canton & Cohort) keep(zwgrowth_rate_1) 
																   
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(canton_survey_year yob)
outreg2 using table_e3_panel_a.doc, append dec(3) nocons addtext(Cluster, Canton x Survey Year & Cohort) keep(zwgrowth_rate_1) 			
		
		
//--------------------------------------------------------
//Create Table E3 (Panel B)
//--------------------------------------------------------

qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idpers)
standardize trust_fed_govt_med

//Column 1
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idpers)
outreg2 using table_e3_panel_b.doc, replace dec(3) nocons addtext(Cluster, Individual) keep(zwgrowth_rate_1) 

//Column 2												   
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(yob)
outreg2 using table_e3_panel_b.doc, append dec(3) nocons addtext(Cluster, Cohort) keep(zwgrowth_rate_1) 
																   
//Column 3
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(canton)
outreg2 using table_e3_panel_b.doc, append dec(3) nocons addtext(Cluster, Canton) keep(zwgrowth_rate_1) 		

//Column 4		
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(canton yob)
outreg2 using table_e3_panel_b.doc, append dec(3) nocons addtext(Cluster, Canton & Cohort) keep(zwgrowth_rate_1) 

//Column 5																   
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(canton_survey_year yob)
outreg2 using table_e3_panel_b.doc, append dec(3) nocons addtext(Cluster, Canton x Survey Year & Cohort) keep(zwgrowth_rate_1) 


//--------------------------------------------------------
//Create Table E4 (Panel A)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>1 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob) //at least 2 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>1 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_a.doc, replace dec(3) nocons addtext(No. of Observations, 2+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>2 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob) //at least 3 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>2 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_a.doc, append dec(3) nocons addtext(No. of Observations, 3+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 3
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>7 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob) //at least 8 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>7 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_a.doc, append dec(3) nocons addtext(No. of Observations, 8+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 
															 
//Column 4
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>9 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob) //at least 10 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>9 & total_obs!=. & age>=15 & age!=., absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_a.doc, append dec(3) nocons addtext(No. of Observations, 10+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 
															 

//--------------------------------------------------------
//Create Table E4 (Panel B)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>1 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob) //at least 2 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>1 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_b.doc, replace dec(3) nocons addtext(No. of Observations, 2+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 2															 
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>2 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob) //at least 3 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>2 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_b.doc, append dec(3) nocons addtext(No. of Observations, 3+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 3															 
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>7 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob) //at least 8 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>7 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_b.doc, append dec(3) nocons addtext(No. of Observations, 8+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 4															 
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if live_switz==1 & total_obs>9 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob) //at least 10 observations
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if live_switz==1 & total_obs>9 & total_obs!=. & age>=15 & age!=., absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e4_panel_b.doc, append dec(3) nocons addtext(No. of Observations, 10+) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 


//--------------------------------------------------------
//Create Table E5
//--------------------------------------------------------

//Column 1
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e5.doc, replace dec(3) nocons addtext(Individual FE, Yes, ///
														  Canton FE, Yes, ///
														  Survey Year FE, Yes, ///
														  Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
														 Canton FE, No, ///
														 Survey Year FE, No, ///
														 Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 
																			
//Column 3
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
standardize_var wincome_growth_1
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
														 Canton FE, Yes, ///
														 Survey Year FE, Yes, ///
														 Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1) 

//Column 4
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
qui reghdfe trust_fed_govt_med wgrowth_rate_1 wincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
standardize_var wincome_growth_1
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_e5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
														 Canton FE, No, ///
														 Survey Year FE, No, ///
														 Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)


//--------------------------------------------------------
//Create Table E6
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, replace dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1)
													   

//Column 3
qui reghdfe trust_fed_govt_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 4
qui reghdfe trust_fed_govt_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 5
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 6
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 7
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 8
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idhous) cluster(idhous yob)
outreg2 using table_e6.doc, append dec(3) nocons addtext(Household FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Households", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)
